Teacher Version

Hero Image
Hero Image

Threshold Value

Threshold Values

The Wait - Ultrasonic Sensor Block uses a threshold to define what it is waiting for. Rather than look for a specific value (like 1cm or 200cm), it sets a "cutoff" value that divides all the possible Ultrasonic Sensor values into two categories:

  • If the distance value is above the threshold, it is considered far
  • If the distance value is below the threshold, it is considered near

Setup:

  • Place robot facing a wall that is more than 75cm away.
  • Write a program that runs toward a wall, and changes the LED color as gets closer:
    • Turn the light green until the sensor detects the wall closer than 75cm.
    • Then turn the light orange until 50cm.
    • Then turn the light red until 25cm.
    • Stop when the robot gets closer than 25cm.

Virtual Robot: ThresholdValueVR.rbg

Physical Robot: ThresholdValue.rbg

Quick Tips

Use these hints below to help you to solve the challenge.

  • Use multiple waitUntil commands in your program.
  • Pause for a couple of seconds after commands for consistency.
  • Can't remember how to use LED Feedback?
    • It can be hard to tell which part of your program the robot is running when your programs have multiple steps.
    • Add the setLEDColor command to these spots in your program with different colors to visually see how your robot is running your program.

© 2016 Robomatter, Inc.

Portions of this product are manufactured under license from Carnegie Mellon University.